package handlers.itemhandlers;

import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;

public class ClanRepItem implements IItemHandler
{
    private static final int ITEM_IDS[] = 
    { 
    	40006
    };

	public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
	{
		if (!(playable instanceof L2PcInstance))
			return;
	
            L2PcInstance activeChar = (L2PcInstance)playable;

            if (!activeChar.isClanLeader())
            {
                activeChar.sendMessage("This can be used only by Clan Leaders!");
                return;
            }
        	 
            else if (!(activeChar.getClan().getLevel() >= 1))
            {
            	activeChar.sendMessage("Your Clan Level is not big enough to use this item!");
            	return;
            }
            else
            {
            	activeChar.getClan().setReputationScore(activeChar.getClan().getReputationScore()+10000, true);
            	activeChar.sendMessage("Your clan has earned "+ 10000 +" rep points!");
            	MagicSkillUse  MSU = new MagicSkillUse(activeChar, activeChar, 2024, 1, 1, 0);
            	activeChar.broadcastPacket(MSU);
              playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
            }
        }

    public int[] getItemIds()
    {
        return ITEM_IDS;
    }

}